<template>
    <div>
        <baidu-map class="map" :center="map.center" :zoom="map.zoom" @ready="handler">
            <!--缩放-->
            <bm-navigation anchor="BMAP_ANCHOR_TOP_LEFT"></bm-navigation>
            <!--定位-->
            <bm-geolocation anchor="BMAP_ANCHOR_BOTTOM_RIGHT" :showAddressBar="true" :autoLocation="true"></bm-geolocation>
            <!--点-->
            <bm-marker :position="map.center" :dragging="map.dragging" animation="BMAP_ANIMATION_DROP">
                <bm-circle>这里</bm-circle>
            </bm-marker>
        </baidu-map>
        {{this.$store.getters.city}}
    </div>
</template>

<script>
    import {getAddress} from "../../api/baiduApi";
    export default {
        name: "NetFriendsSpread",
        data: () => ({
            map:{
                center: {lng:105.7747270000, lat: 26.6415090000},
                zoom: 15,
                show: true,
                dragging: true
            },
            location:''
        }),
        methods: {
            handler ({BMap, map}) {
                let me = this;
                console.log(BMap, map)
                // 鼠标缩放
                map.enableScrollWheelZoom(true);
                // 点击事件获取经纬度
                map.addEventListener('click', function (e) {
                    console.log(e.point.lng, e.point.lat)
                })
            },
            getMyAddressInfo(){
                getAddress().then(res => {
                    this.pointX = res.data.point.x;
                    this.pointY = res.data.point.y;
                    this.location = res.data.content.address;

                }).catch(() =>{

                })
            }
        },
        created() {
            this.getMyAddressInfo();
        }
    }
</script>

<style scoped>
    .map {
        width: 100%;
        height: 400px;
    }
</style>